fstats_descriptive_statistics Module



Interfaces

public interface covariance

  • private pure function covariance_array(x, y) result(rst)

    Computes the sample covariance of two data sets.

    The covariance computed is the sample covariance such that .

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in), dimension(:) :: x

    The first N-element data set.

    real(kind=real64), intent(in), dimension(size(x)) :: y

    The second N-element data set.

    Return Value real(kind=real64)

    Sample covariance; fewer than two observations or nonfinite inputs give NaN. An unrepresentable result gives signed infinity.

  • private pure function covariance_columns(x, y) result(rst)

    Computes sample covariance using independent copies of two columns. Unequal counts cause ERROR STOP with FS_ARRAY_SIZE_ERROR.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(in) :: x

    Paired observation columns, unchanged; unallocated storage is empty.

    class(data_column), intent(in) :: y

    Paired observation columns, unchanged; unallocated storage is empty.

    Return Value real(kind=real64)

    Sample covariance; fewer than two pairs or nonfinite values give NaN. Unrepresentable results give signed infinity.

  • private pure function covariance_column_array(x, y) result(rst)

    Computes sample covariance between a column and an array, copying the column. Unequal counts cause ERROR STOP with FS_ARRAY_SIZE_ERROR.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(in) :: x

    The first observation column, unchanged; unallocated storage is empty.

    real(kind=real64), intent(in), dimension(:) :: y

    The paired observations; must have x's count.

    Return Value real(kind=real64)

    Sample covariance; undersized/nonfinite data give NaN; unrepresentable results give signed infinity.

  • private pure function covariance_array_column(x, y) result(rst)

    Computes sample covariance between an array and a column, copying the column. Unequal counts cause ERROR STOP with FS_ARRAY_SIZE_ERROR.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in), dimension(:) :: x

    The first observation array.

    class(data_column), intent(in) :: y

    The paired observation column, unchanged; must have size(x) values. Unallocated storage is treated as empty.

    Return Value real(kind=real64)

    Sample covariance; undersized/nonfinite data give NaN; unrepresentable results give signed infinity.

public interface mean

Computes the mean of a set of data.

  • private pure function mean_array(x) result(rst)

    Computes the mean using a scaled, compensated sum.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: x(:)

    The array of values to analyze.

    Return Value real(kind=real64)

    Mean; empty arrays or nonfinite observations give NaN.

  • private pure function mean_column(x) result(rst)

    Computes a column mean using a scaled, compensated sum without copying data.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(in) :: x

    The input column; unallocated storage is treated as empty.

    Return Value real(kind=real64)

    Mean; empty arrays or nonfinite observations give NaN.

public interface median

  • private pure function median_array(x) result(rst)

    Computes the median of the values in an array.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: x(:)

    The array of values to analyze.

    Return Value real(kind=real64)

    Median; empty arrays or nonfinite observations give NaN.

  • private pure function median_column(x) result(rst)

    Computes the median by sorting a copy, leaving the column unchanged.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(in) :: x

    The input column; unallocated storage is treated as empty.

    Return Value real(kind=real64)

    Median; empty or nonfinite data give NaN.

public interface pooled_variance

Computes the pooled estimate of variance.

  • private pure function pooled_variance_1(si, ni) result(rst)

    Computes the pooled estimate of variance.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in), dimension(:) :: si

    An N-element array containing the estimates for each of the N variances.

    integer(kind=int32), intent(in), dimension(size(si)) :: ni

    An N-element array containing the number of data points in each of the data sets used to compute the variances in si.

    Return Value real(kind=real64)

    Pooled variance; empty inputs, nonfinite/negative variances, or groups with fewer than two observations give NaN.

  • private pure function pooled_variance_2(x) result(rst)

    Computes the pooled estimate of variance.

    Arguments

    Type IntentOptional Attributes Name
    type(array_container), intent(in), dimension(:) :: x

    An array of arrays of data.

    Return Value real(kind=real64)

    Pooled variance; empty/unallocated groups or groups with fewer than two finite observations give NaN.

  • private pure function pooled_variance_column(si, ni) result(rst)

    Pools variance estimates using the array implementation on a column copy. Unequal counts cause ERROR STOP with FS_ARRAY_SIZE_ERROR.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(in) :: si

    Group variance estimates, unchanged; unallocated storage is empty.

    integer(kind=int32), intent(in), dimension(:) :: ni

    Group observation counts; must have si's count and each be at least two.

    Return Value real(kind=real64)

    Pooled variance; empty data, negative/nonfinite estimates, or invalid group sizes give NaN.

  • private pure function pooled_variance_columns(x) result(rst)

    Pools sample variances from an array of columns, copying each group's data.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(in), dimension(:) :: x

    Observation columns; groups may have different row counts.

    Return Value real(kind=real64)

    Pooled variance; no groups, undersized/unallocated groups, or nonfinite observations give NaN, as in the array-container overload.

public interface quantile

  • private pure function quantile_array(x, q) result(rst)

    Computes the specified quantile of a data set using the SAS Method 4.

    See Also

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: x(:)

    An N-element array containing the data.

    real(kind=real64), intent(in) :: q

    The quantile to compute (e.g. 0.25 computes the 25% quantile).

    Return Value real(kind=real64)

    Quantile; empty/nonfinite data or q outside [0, 1] give NaN.

  • private pure function quantile_column(x, q) result(rst)

    Computes a quantile using the array implementation on a copy.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(in) :: x

    The input column, unchanged; unallocated storage is treated as empty.

    real(kind=real64), intent(in) :: q

    The quantile probability in [0, 1], using the array routine's interpolation.

    Return Value real(kind=real64)

    Quantile; empty/nonfinite data or invalid/nonfinite q give NaN.

public interface standard_deviation

  • private pure function standard_deviation_array(x) result(rst)

    Computes the sample standard deviation of the values in an array.

    The value computed is the sample standard deviation.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: x(:)

    The array of values to analyze.

    Return Value real(kind=real64)

    Sample standard deviation; invalid/undersized data give NaN. It can remain finite even when the variance would overflow.

  • private pure function standard_deviation_column(x) result(rst)

    Computes sample standard deviation using the array implementation on a copy.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(in) :: x

    The input column, unchanged; unallocated storage is treated as empty.

    Return Value real(kind=real64)

    Sample standard deviation; fewer than two values or nonfinite data give NaN. Unrepresentable results give positive infinity.

public interface trimmed_mean

  • private function trimmed_mean_array(x, p) result(rst)

    Computes the trimmed mean of a data set.

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(inout), dimension(:) :: x

    An N-element array containing the data. On output, the array is sorted into ascending order.

    real(kind=real64), intent(in), optional :: p

    An optional parameter specifying the percentage of values from either end of the distribution to remove. The default is 0.05 such that the bottom 5% and top 5% are removed.

    Return Value real(kind=real64)

    Trimmed mean; invalid p or empty/nonfinite data give NaN.

  • private function trimmed_mean_column(x, p) result(rst)

    Computes the trimmed mean and sorts the column's values in ascending order. Uses a borrowed view without reallocating the underlying array.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(inout), target :: x

    The input column; sorted on success, unchanged for invalid inputs. Unallocated storage is treated as empty.

    real(kind=real64), intent(in), optional :: p

    Fraction to remove from each end, in [0, 0.5); defaults to 0.05.

    Return Value real(kind=real64)

    Trimmed mean; empty/nonfinite data or invalid/nonfinite p give NaN.

public interface variance

  • private pure function variance_array(x) result(rst)

    Computes the sample variance of the values in an array.

    The variance computed is the sample variance such that .

    Arguments

    Type IntentOptional Attributes Name
    real(kind=real64), intent(in) :: x(:)

    The array of values to analyze.

    Return Value real(kind=real64)

    Sample variance; fewer than two observations or nonfinite inputs give NaN. An unrepresentable variance gives positive infinity.

  • private pure function variance_column(x) result(rst)

    Computes sample variance using the array implementation on a copy.

    Arguments

    Type IntentOptional Attributes Name
    class(data_column), intent(in) :: x

    The input column, unchanged; unallocated storage is treated as empty.

    Return Value real(kind=real64)

    Sample variance; fewer than two values or nonfinite data give NaN. Unrepresentable results give positive infinity.